package logic

import (
	"baidutieba/tiebarpc/tiebarpcclient"
	"context"

	"baidutieba/api/internal/svc"
	"baidutieba/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type PerfectRequestLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewPerfectRequestLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PerfectRequestLogic {
	return &PerfectRequestLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *PerfectRequestLogic) PerfectRequest(req *types.PerfectRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	sms, err := l.svcCtx.TiebaRpc.Perfect(l.ctx, &tiebarpcclient.PerfectRequest{
		UserImage: req.UserImage,
		Info:      req.Info,
		NickName:  req.NickName,
		UserId:    req.UserId,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "完善信息成功",
		Code:    200,
		Data:    sms,
	}, nil

}
